﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Dummy
{
    public partial class LoginWindow : ChildWindow
    {
        public string gamerName { get { return tb_gamer_name.Text; } }
        public delegate void EventLogin(string gamerName);
        public event EventLogin onLogin;

        public LoginWindow()
        {
            InitializeComponent();
            tbl_error.Text = "";
        }

        public void ShowError(string errorMessage)
        {
            tbl_error.Text = errorMessage;
        }

        public void ProcessingLogin(bool process)
        {
            if (process)
            {
                tb_gamer_name.IsEnabled = false;
                bt_login.IsEnabled = false;
            }
            else
            {
                tb_gamer_name.IsEnabled = true;
                bt_login.IsEnabled = true;
            }
        }        

        private void bt_login_click(object sender, RoutedEventArgs e)
        {
            //this.DialogResult = true;
            invokeLogin();
        }

        private void tb_gamer_name_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
                invokeLogin();
        }

        private void invokeLogin()
        {
            if (onLogin != null)
                onLogin(gamerName);
        }
    }
}

